+1999-11-04 Jonathan Blandford <jrb@redhat.com>
+
+ * src/gdk-pixbuf-loader.c (gdk_pixbuf_loader_update): handle the
+ actual update.
+ * src/io-png.c (image_begin_load): add a update_func callback.
+ * src/io-gif.c (image_begin_load): add a update_func callback.
+ * src/io-tiff.c (image_begin_load): add a update_func callback.
+
1999-11-04 Federico Mena Quintero <federico@redhat.com>
* doc/tmpl/gdk-pixbuf.sgml: Populated.
\f
typedef void (* ModulePreparedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data);
+typedef void (* ModuleUpdatedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data, guint x, guint y, guint width, guint height);
typedef struct _GdkPixbufModule GdkPixbufModule;
struct _GdkPixbufModule {
GdkPixbuf *(* load_xpm_data) (const gchar **data);
/* Incremental loading */
- gpointer (* begin_load) (ModulePreparedNotifyFunc func, gpointer user_data);
+ gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func, ModuleUpdatedNotifyFunc update_func, gpointer user_data);
void (* stop_load) (gpointer context);
gboolean (* load_increment)(gpointer context, const gchar *buf, guint size);
};
gtk_signal_emit (GTK_OBJECT (loader), pixbuf_loader_signals[AREA_PREPARED]);
}
+static void
+gdk_pixbuf_loader_update (GdkPixbuf *pixbuf, gpointer loader, guint x, guint y, guint width, guint height)
+{
+ GdkPixbufLoaderPrivate *priv = NULL;
+
+ priv = GDK_PIXBUF_LOADER (loader)->private;
+
+ gtk_signal_emit (GTK_OBJECT (loader),
+ pixbuf_loader_signals[AREA_UPDATED],
+ x, y,
+ /* sanity check in here. Defend against an errant loader */
+ MIN (width, gdk_pixbuf_get_width (priv->pixbuf)),
+ MIN (height, gdk_pixbuf_get_height (priv->pixbuf)));
+}
+
\f
/**
return 0;
}
- priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, loader);
+ priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, gdk_pixbuf_loader_update, loader);
if (priv->context == NULL) {
g_warning("Failed to begin progressive load");
void (* area_prepared) (GdkPixbufLoader *loader);
void (* area_updated) (GdkPixbufLoader *loader,
- int x, int y, int width, int height);
+ guint x, guint y, guint width, guint height);
void (* closed) (GdkPixbufLoader *loader);
};
FILE *file;
/* progressive read, only. */
- ModulePreparedNotifyFunc func;
+ ModulePreparedNotifyFunc prepare_func;
+ ModuleUpdatedNotifyFunc update_func;
gpointer user_data;
guchar *buf;
guint ptr;
context->width,
context->height);
- if (context->func)
- (* context->func) (context->pixbuf, context->user_data);
+ if (context->prepare_func)
+ (* context->prepare_func) (context->pixbuf, context->user_data);
}
dest = gdk_pixbuf_get_pixels (context->pixbuf);
*(temp+2) = context->color_map [2][(guchar) v];
}
- if (context->func && context->frame_interlace)
+ if (context->prepare_func && context->frame_interlace)
gif_fill_in_lines (context, dest, v);
context->draw_xpos++;
context->file = file;
context->pixbuf = NULL;
context->state = GIF_START;
- context->func = NULL;
+ context->prepare_func = NULL;
+ context->update_func = NULL;
gif_main_loop (context);
}
gpointer
-image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
+image_begin_load (ModulePreparedNotifyFunc prepare_func,
+ ModuleUpdatedNotifyFunc update_func,
+ gpointer user_data)
{
GifContext *context;
count = 0;
#endif
context = g_new (GifContext, 1);
- context->func = func;
+ context->prepare_func = prepare_func;
context->user_data = user_data;
context->file = NULL;
context->pixbuf = NULL;
};
gpointer
-image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
+image_begin_load (ModulePreparedNotifyFunc prepare_func,
+ ModuleUpdatedNotifyFunc update_func,
+ gpointer user_data)
{
LoadContext* lc;
lc->fatal_error_occurred = FALSE;
- lc->notify_func = func;
+ lc->notify_func = prepare_func;
lc->notify_user_data = user_data;
/* Create the main PNG context struct */
typedef struct _TiffData TiffData;
struct _TiffData
{
- ModulePreparedNotifyFunc func;
+ ModulePreparedNotifyFunc prepare_func;
+ ModuleUpdatedNotifyFunc update_func;
gpointer user_data;
gchar *tempname;
pixbuf = gdk_pixbuf_new (ART_PIX_RGB, TRUE, 8, w, h);
if (context)
- (* context->func) (pixbuf, context->user_data);
+ (* context->prepare_func) (pixbuf, context->user_data);
/* Yes, it needs to be _TIFFMalloc... */
rast = (uint32 *) _TIFFmalloc (num_pixs * sizeof (uint32));
_TIFFfree (rast);
TIFFClose (tiff);
- if (context)
+ if (context) {
gdk_pixbuf_unref (pixbuf);
+ (* context->update_func) (pixbuf, context->user_data, 0, 0, w, h);
+ }
return pixbuf;
}
* the file when it's done. It's not pretty.
*/
+
gpointer
-image_begin_load (ModulePreparedNotifyFunc func, gpointer user_data)
+image_begin_load (ModulePreparedNotifyFunc prepare_func,
+ ModuleUpdatedNotifyFunc update_func,
+ gpointer user_data)
{
TiffData *context;
gint fd;
context = g_new (TiffData, 1);
- context->func = func;
+ context->prepare_func = prepare_func;
context->user_data = user_data;
context->all_okay = TRUE;
context->tempname = g_strdup ("/tmp/gdkpixbuf-tif-tmp.XXXXXX");
gtk_signal_emit (GTK_OBJECT (loader), pixbuf_loader_signals[AREA_PREPARED]);
}
+static void
+gdk_pixbuf_loader_update (GdkPixbuf *pixbuf, gpointer loader, guint x, guint y, guint width, guint height)
+{
+ GdkPixbufLoaderPrivate *priv = NULL;
+
+ priv = GDK_PIXBUF_LOADER (loader)->private;
+
+ gtk_signal_emit (GTK_OBJECT (loader),
+ pixbuf_loader_signals[AREA_UPDATED],
+ x, y,
+ /* sanity check in here. Defend against an errant loader */
+ MIN (width, gdk_pixbuf_get_width (priv->pixbuf)),
+ MIN (height, gdk_pixbuf_get_height (priv->pixbuf)));
+}
+
\f
/**
return 0;
}
- priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, loader);
+ priv->context = (*priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, gdk_pixbuf_loader_update, loader);
if (priv->context == NULL) {
g_warning("Failed to begin progressive load");
void (* area_prepared) (GdkPixbufLoader *loader);
void (* area_updated) (GdkPixbufLoader *loader,
- int x, int y, int width, int height);
+ guint x, guint y, guint width, guint height);
void (* closed) (GdkPixbufLoader *loader);
};